/*
 * @Author: zhouwei wei.zhou@flip.fun
 * @Date: 2024-04-07 23:08:30
 * @LastEditors: zhouwei wei.zhou@flip.fun
 * @LastEditTime: 2024-04-07 23:30:17
 * @FilePath: /50/手撕系列/throttle.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
/**
 *
 * @param {Function} fn
 */
function throttle(fn, time) {
	let timer = null
	return function (...args) {
		if (timer) {
			return
		}
		timer = setTimeout(() => {
			fn.call(this, ...args)
            clearTimeout(timer);
			timer = null
		}, time)
	}
}
